---
category: Number
created: '2020-04-23'
title: Compute the greatest common divisor between two numbers
updated: '2021-10-13'
---

**JavaScript version**

```js gcd.js
const gcd = (a, b) => (b === 0 ? a : gcd(b, a % b));
```

**TypeScript version**

```ts gcd.ts
const gcd = (a: number, b: number): number => (b === 0 ? a : gcd(b, a % b));
```

**Examples**

```js examples.js
gcd(10, 15); // 5
```
